package com.example.mybatis.mapper.dao;

import com.example.mybatis.mapper.entity.User;
import io.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author fanhang
 */
@Mapper
public interface UserMapper extends BaseMapper<User, Long> {

    @Select("select * from t_user where age = #{age} ")
    List<User> findByAge(@Param("age") int age);

    default List<User> findGreaterAgeLikeName(int age, String name) {
        return wrapper().gt(User::getAge, age).like(User::getName, name).list();
    }

}
